import time
from concurrent.futures import ThreadPoolExecutor, as_completed

Tpe = ThreadPoolExecutor(max_workers=5)


def excutor(t):
    if type(t) == str:
        print(' %s finished' % t)
        return t
    else:
        time.sleep(t)
        print('this is :%s finished' % t)
        return t


urls = [6, 2, 6, 4, 5]
names = ['mark', 'tolle', 'rose', 'blues', 'linus', 'newman']
alltask = [Tpe.submit(excutor, u) for u in urls]
# as_complete 具有谁先完成任务，返回谁的句柄
for items in as_completed(alltask):
    print(items.done())

# map 写法更简便，自动映射参数，另外输出顺序按照输入顺序进行输出
[print(i) for i in Tpe.map(excutor,urls)]